<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<!DOCTYPE html>
<html>

<head>
    <base href="${pageContext.request.contextPath}/"/>
    <title>襄阳蓝芯智能化办公系统</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        /*定义类名为.thead-blue的样式*/
        .thead-blue {
            color: #fff;
            font-weight: bold;
            background-color: #337ab7;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="view/bootstrap-3.3.5/css/bootstrap.css"/>
    <link rel="stylesheet" type="text/css" href="view/bootstrapvalidator/css/bootstrapValidator.css"/>
    <script charset="utf-8" src="view/jquery/jquery-1.10.2.min.js"></script>
    <script charset="utf-8" src="view/bootstrap-3.3.5/js/bootstrap.js"></script>
    <script charset="utf-8" src="view/bootstrapvalidator/js/bootstrapValidator.js"></script>

</head>
<body>

<!-- 搜索 -->
<div class="panel panel-primary">
    <div class="panel-heading">
        <h4 class="panel-title">我的所有申请单</h4>
    </div>
    <div class="panel-body">
        <form action="flow/listMyFlow" id="seachform" method="post"
              class="form-horizontal" role="form">
            <div class="form-group">
                <div class="col-md-6">
                    <label for="docNo" class="col-md-3 control-label">单据编号</label>
                    <div class="col-md-8">
                        <input type="text" name="docNo" id="docNo" class="form-control"
                               placeholder="请输入单据编号" value="${approval.docNo }">
                        <input type="hidden" name="page" id="page" value="${pageBean.page }">
                        <input type="hidden" name="pageSize" id="pageSize" value="${pageBean.pageSize }">
                    </div>
                </div>
                <div class="col-md-6">
                    <label for="docType" class="col-md-3 control-label">单据类型</label>
                    <div class="col-md-8">
                        <select name="docType" id="docType" class="form-control">
                            <option value="">--请选择--</option>
                            <c:forEach items="${lcFlow }" var="d">
                                <option value="${d.docType}" ${d.docType==approval.docType?"selected":"" }>
                                    --${d.flowName }---
                                </option>
                            </c:forEach>
                        </select>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-6">
                    <label for="submitDate" class="col-md-3 control-label">开始时间</label>
                    <div class="col-md-8">
                        <input type="date" id="submitDate" name="submitDate"
                               class="form-control"
                               value="<fmt:formatDate value='${approval.submitDate}' pattern='yyyy-MM-dd'/>">
                    </div>
                </div>
                <div class="col-md-6">
                    <label for="status" class="col-md-3 control-label">审批状态</label>
                    <div class="col-md-8">
                        <select name="status" id="status" class="form-control">
                            <option value="">--请选择--</option>
                            <option value="S" ${approval.status=='S'?"selected":"" }>--审批中--</option>
                            <option value="Y" ${approval.status=='Y'?"selected":"" }>--审批通过--</option>
                            <option value="N" ${approval.status=='N'?"selected":"" }>--审批不通过--</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <div class="col-md-6">
                    <label for="approvalDate" class="col-md-3 control-label">结束时间</label>
                    <div class="col-md-8">
                        <input type="date" id="approvalDate" name="approvalDate"
                               class="form-control"
                               value="<fmt:formatDate value='${approval.approvalDate}' pattern='yyyy-MM-dd'/>">
                    </div>
                </div>

                <div class="col-md-6">
                    <div class="col-md-3 col-md-offset-3">
                        <button type="button" onclick="searchBtn()" class="btn btn-success">搜索待审批单据</button>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>


<!-- 列表 -->
<div class="panel panel-primary">
    <table class="table table-bordered table-hover">
        <thead>
        <tr class="thead-blue" align="center">
            <td>单据编号</td>
            <td>单据类型</td>
            <td>提交时间</td>
            <td>审批时间</td>
            <td>状态</td>
            <td>查看审批历史</td>
        </tr>
        </thead>
        <tbody>
        <c:forEach items="${pageBean.data }" var="a">
            <tr align="center">
                <td>${a.docNo }</td>
                <td>
                        ${a.docType=='BXD'?"报销申请单":"" }
                        ${a.docType=='GMD'?"资产购买申请单":"" }
                        ${a.docType=='YDD'?"资产移动申请单":"" }
                </td>
                <td>
                    <fmt:formatDate value='${a.submitDate}' pattern='yyyy-MM-dd HH:mm:ss'/>
                </td>
                <td>
                    <fmt:formatDate value='${a.approvalDate}' pattern='yyyy-MM-dd HH:mm:ss'/>
                </td>
                <td>
                        ${a.status=='S'?"审批中":"" }
                        ${a.status=='Y'?"审批通过":"" }
                        ${a.status=='N'?"审批不通过":"" }
                </td>
                <td>
                    <button type="button"
                            onclick="location.href='apply/BxInfo?oid=${a.docid}'" class="btn btn-info btn-xs">详情
                    </button>
                    <button type="button" onclick="location.href='flow/approvalLog?docNo=${a.docNo }'"
                            class="btn btn-success btn-xs">查看审批历史
                    </button>
                </td>
            </tr>
        </c:forEach>
        </tbody>
    </table>
</div>

<!-- 分页 -->
<div class="input-group col-md-6 col-md-offset-3">
    <div class="row">
        <div class="btn-group">
            <button onclick="gotoPage(1,${pageBean.pageSize})"
                    class="btn btn-primary" type="button">首页
            </button>
            <c:if test="${pageBean.page==1 }">
                <button class="btn btn-primary disabled" type="button">上一页</button>
            </c:if>
            <c:if test="${pageBean.page>1 }">
                <button onclick="gotoPage(${pageBean.page-1},${pageBean.pageSize})"
                        class="btn btn-primary" type="button">上一页
                </button>
            </c:if>

            <button class="btn btn-primary disabled" type="button">当前第${pageBean.page}/${pageBean.pageCount}页</button>

            <div class="btn-group">
                <button type="button" class="btn btn-primary dropdown-toggle"
                        data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    每页显示${pageBean.pageSize}条 <span class="caret"></span>
                </button>
                <ul class="dropdown-menu">
                    <li><a href="javascript:gotoPage(1,5)">每页显示5条</a></li>
                    <li><a href="javascript:gotoPage(1,10)">每页显示10条</a></li>
                    <li><a href="javascript:gotoPage(1,15)">每页显示15条</a></li>
                    <li><a href="javascript:gotoPage(1,20)">每页显示20条</a></li>
                </ul>
            </div>

            <button class="btn btn-primary disabled" type="button">共${pageBean.rowCount}条记录</button>

            <c:if test="${pageBean.page==pageBean.pageCount }">
                <button class="btn btn-primary disabled" type="button">下一页</button>
            </c:if>
            <c:if test="${pageBean.page<pageBean.pageCount }">
                <button onclick="gotoPage(${pageBean.page+1},${pageBean.pageSize})"
                        class="btn btn-primary" type="button">下一页
                </button>
            </c:if>
            <button
                    onclick="gotoPage(${pageBean.pageCount },${pageBean.pageSize})"
                    class="btn btn-primary" type="button">尾页
            </button>
        </div>
    </div>
</div>


<br>
<br>
<br>

<%@include file="../modal/confirm.jsp" %>
<%@include file="../modal/alertmsg.jsp" %>
<script type="text/javascript">
    $(document).ajaxError(function (event, xhr) {
        if (xhr.status == "403") {//没有权限
            document.location.href = xhr.getResponseHeader("url");
        } else if (xhr.status != "200") {
            //alert("服务器错误!");
            console.log("服务器错误!");
        }
    });
</script>

</body>
<script type="text/javascript">
    function gotoPage(page, pageSize) {
        $("#page").val(page);
        $("#pageSize").val(pageSize);
        $("#seachform").submit();
    }

    function searchBtn() {
        $("#page").val(1);
        $("#seachform").submit();
    }


</script>
</html>